package com.duapk.search.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.duapk.search.constant.Constant;
import com.duapk.search.work.IndexSearcherManager;

/**
 * 索引更新通知接口
 * 
 * @Package: com.duapk.search.servlet
 * @ClassName: NotifyServlet
 * @author: jiangzheng
 * @date: Apr 5, 2011 4:47:06 PM
 * 
 */
@SuppressWarnings("serial")
public class NotifyServlet extends HttpServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String ts = req.getParameter("ts");
		IndexSearcherManager.updateIndexSearch(ts);
		resp.setContentType("text/html;charset=" + Constant.UTF_ENCODING);
		PrintWriter out = resp.getWriter();
		out.write("OK");
		out.flush();
		out.close();
	}
}
